import 'package:flutter/material.dart';
import 'package:sui_shou_pai/module/effect.dart';
import 'package:sui_shou_pai/record/record_detail.dart';
import 'package:sui_shou_pai/record/record_entity/photo_record_entity.dart';

Widget initRecordListItem(BuildContext context, PhotoRecordEntity item) {
  return GestureDetector(
    onTap: () {
      Navigator.push(
          context,
          MaterialPageRoute(
              builder: (context) => RecordDetail(),
              settings: RouteSettings(arguments: item)));
    },
    child: Container(
      margin: EdgeInsets.fromLTRB(8, 8, 8, 0),
      padding: EdgeInsets.all(12),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: borderRadiusAll8(),
        boxShadow: [shadowOffsetY2()],
      ),
      child: Row(
        children: <Widget>[
          initRecordText(item.content, item.updateTime),
          initRecordImage(item.image)
        ],
      ),
    ),
  );
}

Widget initRecordText(String title, String time) {
  return Expanded(
      child: Container(
    height: 100,
    padding: EdgeInsets.only(right: 12),
    child: Column(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      crossAxisAlignment: CrossAxisAlignment.start,
      children: <Widget>[
        initRecordTitle(title),
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: <Widget>[
            initRecordTime(time),
            // initNewsLikeComment(likeCount, commentCount)
          ],
        )
      ],
    ),
  ));
}

Widget initRecordTitle(String title) {
  return Text(
    title,
    style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
  );
}

Widget initRecordTime(String time) {
  return Text(
    '$time ',
    style: TextStyle(fontSize: 14, color: Colors.grey),
  );
}

Widget initRecordImage(String headerImagePath) {
  return ClipRRect(
    borderRadius: borderRadiusAll4(),
    child: Image.network(headerImagePath.split(",")[0],
        height: 100, width: 140, fit: BoxFit.cover),
  );
}
